package com.glodon.ggzy.fwpt.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.glodon.ggzy.core.model.Page;
import com.glodon.ggzy.core.utils.PageSearchModel;
import com.glodon.ggzy.entity.GgCqLaw;
import com.glodon.ggzy.entity.GgCqTbgg;
import com.glodon.ggzy.entity.GgCqZbcjgg;
import com.glodon.ggzy.entity.GgJsTenderNotice;
import com.glodon.ggzy.fwpt.dao.IGgCqLawDao;
import com.glodon.ggzy.fwpt.dao.IGgCqTbggDao;
import com.glodon.ggzy.fwpt.dao.IGgCqXmGgzyDao;
import com.glodon.ggzy.fwpt.dao.IGgCqZbcjggDao;
import com.glodon.ggzy.fwpt.service.ICqjyProjectService;

/**
 * 
 * 产权交易处理Service实现类
 * 
 * @author yangjf
 * @date 2013/06/11
 */
@Service
public class CqjyProjectServiceImpl implements ICqjyProjectService {

	protected Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	private IGgCqXmGgzyDao ggcqXmGgzyDao;
	@Autowired
	private IGgCqTbggDao tbggDao;
	@Autowired
	private IGgCqZbcjggDao zbggDao;

	@Autowired
	private IGgCqLawDao lawDao;

	@Override
	public Page queryPage(PageSearchModel queryModel) {
		// queryModel.addParamToMap("prjName_is_not_null", null);
		// queryModel.addParamToMap("prjNo_like", "%1%");
		// queryModel.addParamToMap("prjName|prjNo", "1");
		// queryModel.addParamToMap("prjName_like|prjNo_like", "%1%");
		return ggcqXmGgzyDao.pageQuery(queryModel.getParamsMap(), queryModel
				.getPageNo(), queryModel.getPageSize());
	}

	@Override
	public GgCqLaw getGgCqLawById(String id) {
		return lawDao.get(id);
	}

	@Override
	public GgCqTbgg getTbggById(String id) {
		try {
			GgCqTbgg tbgg = null;
			List<GgCqTbgg> list = new ArrayList<GgCqTbgg>();
			DetachedCriteria criteria = DetachedCriteria
					.forClass(GgCqTbgg.class);
			criteria.add(Restrictions.eq("id", id));
			list = tbggDao.findByDetachedCriteria(criteria);
			if (list != null && list.size() > 0) {
				tbgg = list.get(0);
			}
			return tbgg;
		} catch (Exception ex) {
			logger.error("获取数据失败！", ex);
			return null;
		}
	}

	@Override
	public GgCqZbcjgg getZbgsById(String id) {
		try {
			GgCqZbcjgg zbgs = null;
			List<GgCqZbcjgg> list = new ArrayList<GgCqZbcjgg>();
			DetachedCriteria criteria = DetachedCriteria
					.forClass(GgCqZbcjgg.class);
			criteria.add(Restrictions.eq("id", id));
			list = zbggDao.findByDetachedCriteria(criteria);
			if (list != null && list.size() > 0) {
				zbgs = list.get(0);
			}
			return zbgs;
		} catch (Exception ex) {
			logger.error("获取数据失败！", ex);
			return null;
		}
	}

}
